package pub.tbc.api.config;

import lombok.extern.slf4j.Slf4j;
import pub.tbc.toolkit.CastUtil;

import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;

/**
 * @author tbc on 2017/3/2 17:20:16.
 */
@Slf4j
public abstract class AbstractConfiguration implements Configuration {

    protected abstract ResourceBundle getBundle();

    @Override
    public String get(String key) {
        return getBundle().getString(key);
    }

    @Override
    public int getInt(String key) {
        return CastUtil.castInt(get(key));
    }

    @Override
    public long getLong(String key) {
        return CastUtil.castLong(get(key));
    }

    @Override
    public float getFloat(String key) {
        return Float.parseFloat(get(key));
    }

    @Override
    public double getDouble(String key) {
        return CastUtil.castDouble(get(key));
    }

    @Override
    public boolean getBoolean(String key) {
        return CastUtil.castBoolean(get(key));
    }

    @Override
    public <T> T getBean(String key) {
        return null;
    }

    @Override
    public Map<String, Object> getMap() {
        return null;
    }

    @Override
    public Set<String> keySet() {
        return getBundle().keySet();
    }

    @Override
    public boolean containKey(String key) {
        return getBundle().containsKey(key);
    }
}
